package tv.acgn.advertisement.index.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import tv.acgn.advertisement.index.service.DataIndexExportService;
import tv.acgn.advertisement.servicebase.vo.CommonResponse;

/**
 * @author : junG
 * @program : advertisement-ad-index-config
 * @description : 数据库索引访问接口
 * @date : 2019-09-08 17:05
 **/

@RestController
public class DataIndexAction {

    @Autowired
    private DataIndexExportService dataIndexExportService;

    /**
     * <h2>导出推广计划表ad_plan索引的网络接口</h2>
     *
     * @param fileName 导出后的文件名[1]
     *
     * @return {@link CommonResponse}
     *
     * @author junG
     * @description 导出推广计划表Ad_Plan索引
     * @date 23:54 2019/10/31
     */
    @GetMapping("export/adPlan/{fileName}")
    private CommonResponse exportAdPlanDataTable(@PathVariable(name = "fileName", required = false) String fileName) {
        dataIndexExportService.exportAdPlanTable(fileName);
        return CommonResponse.builder().success(true).build();
    }

    /**
     * <h2>导出推广单元数据表ad_unit的网络接口</h2>
     *
     * @param fileName 导出后的文件名[1]
     *
     * @return {@link CommonResponse}
     *
     * @author junG
     * @description 导出推广单元数据表Ad_Unit的网络接口
     * @date 23:55 2019/10/31
     */
    @GetMapping("export/adUnit/{fileName}")
    private CommonResponse exportAdUnitDataTable(@PathVariable(name = "fileName", required = false) String fileName) {
        dataIndexExportService.exportAdUnitTable(fileName);
        return CommonResponse.builder().success(true).build();
    }

    /**
     * <h2>导出创意的数据表creative的网络接口</h2>
     *
     * @param fileName 导出后的文件名[1]
     *
     * @return {@link CommonResponse}
     *
     * @author junG
     * @description 导出创意的数据表creative的网络接口
     * @date 23:56 2019/10/31
     */
    @GetMapping("export/Creative/{fileName}")
    private CommonResponse exportCreativeDataTable(@PathVariable(name = "fileName", required = false) String fileName) {
        dataIndexExportService.exportCreativeTable(fileName);
        return CommonResponse.builder().success(true).build();
    }

    /**
     * <h2>导出创意与推广单元关系的数据表creative_unit的网络接口</h2>
     * @author junG
     * @description 导出创意与推广单元关系的数据表creative_unit的网络接口
     * @date 23:57 2019/10/31
     * @param fileName 导出后的文件名 [1]
     * @return {@link CommonResponse}
     */
    @GetMapping("export/CreativeUnit/{fileName}")
    private CommonResponse exportCreativeUnitDataTable(
        @PathVariable(name = "fileName", required = false) String fileName) {
        dataIndexExportService.exportCreativeUnitTable(fileName);
        return CommonResponse.builder().success(true).build();
    }

    /**
     * <h2>导出推广单元与地区关系的数据表unit_district的网络接口</h2>
     * @author junG
     * @description 导出推广单元与地区关系的数据表unit_district的网络接口
     * @date 23:58 2019/10/31
     * @param fileName 导出后的文件名 [1]
     * @return {@link CommonResponse}
     */
    @GetMapping("export/AdUnitDistrict/{fileName}")
    private CommonResponse exportAdUnitDistrictDataTable(
        @PathVariable(name = "fileName", required = false) String fileName) {
        dataIndexExportService.exportAdUnitDistrictTable(fileName);
        return CommonResponse.builder().success(true).build();
    }

    /**
     * <h2>导出推广单元与兴趣关系的数据表unit_interest的网络接口</h2>
     * @author junG
     * @description 导出推广单元与兴趣关系的数据表unit_interest的网络接口
     * @date 23:59 2019/10/31
     * @param fileName 导出后的文件名[1]
     * @return {@link CommonResponse}
     */
    @GetMapping("export/AdUnitInterest/{fileName}")
    private CommonResponse exportAdUnitInterestDataTable(
        @PathVariable(name = "fileName", required = false) String fileName) {
        dataIndexExportService.exportAdUnitInterestTable(fileName);
        return CommonResponse.builder().success(true).build();
    }

    /**
     * <h2>导出推广单元与关键词关系的数据表unit_keyword的网络接口</h2>
     * @author junG
     * @description 导出推广单元与关键词关系的数据表unit_keyword的网络接口
     * @date 0:00 2019/11/1
     * @param fileName 导出后的文件名[1]
     * @return {@link CommonResponse}
     */
    @GetMapping("export/AdUnitKeyword/{fileName}")
    private CommonResponse exportAdUnitKeywordDataTable(
        @PathVariable(name = "fileName", required = false) String fileName) {
        dataIndexExportService.exportAdUnitKeywordTable(fileName);
        return CommonResponse.builder().success(true).build();
    }
}
